'use strict';
const Service = require('egg').Service;
class userService extends Service {
  constructor(ctx) {
    super(ctx);
  }
  async create(params) {
    const ctx = this.ctx;
    //存储数据库
    console.log(params);
    const res = await  ctx.model.User.create(params);
    return res.dataValues;
  }
  async update(params) {
    const ctx = this.ctx;
    var id = params.id;
    //存储数据库
    console.log(id);
    const res = await ctx.model.User.update(params, { where: { id: id } });
    return res;
  }
  async getUseridByOpenid(openid) {
    const ctx = this.ctx;
    return await ctx.model.User.findOne({raw: true,where: { weixin_openid: openid} });
  }
}

module.exports = userService;